package com.urms.service.impl;

import com.urms.entity.UserRole;
import com.urms.mapper.UserRoleMapper;
import com.urms.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserRoleServiceImpl implements UserRoleService {
    @Autowired
    private UserRoleMapper userRoleMapper;

    @Override
    public List<UserRole> selectRoleByUserId(Integer userId) {
        return userRoleMapper.selectRoleByUserId(userId);
    }

    @Override
    public Integer insertUserRole(String userLoginName, Integer userId, Integer[] roleIds) {
        int i=userRoleMapper.deleteByUserId(userId);
            return userRoleMapper.insertUserRole(userLoginName, userId, roleIds);
    }

    @Override
    public List<String> selectRoleNameByUId(Integer userId) {
        return userRoleMapper.selectRoleNameByUId(userId);
    }
}
